package com.goalias.controller;


import com.goalias.domain.entity.Comment;
import com.goalias.resp.Result;
import com.goalias.service.ICommentService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 评论表 前端控制器
 * </p>
 *
 * @author goalias
 * @since 2024-12-12
 */
@RestController
@RequestMapping("/content/comment")
public class CommentController {

    @Resource
    private ICommentService commentService;

    @GetMapping("/getList")
    public Result getCommentList(Long articleId, @RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "10")Integer pageSize){
        return commentService.getCommentList(articleId, pageNum, pageSize);
    }

    @PostMapping("/add")
    public Result addComment(@RequestBody @Validated Comment comment){
        return commentService.addComment(comment);
    }

    @PostMapping("/update")
    public Result updateComment(@RequestBody @Validated Comment comment){
        return commentService.updateComment(comment);
    }

    @PostMapping("/delete/{id}")
    public Result deleteCommand(@PathVariable("id") Long id){
        return commentService.deleteCommand(id);
    }
}
